<template>
    <el-tabs type="border-card" class="edittabform">
        <el-tab-pane label="数据">
            <el-row type="flex" class="editformitem" align="middle">
                <el-col :span="8" class="editlabel">
                    <span>数据表格</span>
                </el-col>
                <el-col :span="16" class="editcontent">
                    <el-select v-model="obj.tableData.tableId" filterable clearable placeholder="请选择数据" size="mini"
                        @change="tableSelectChange">
                        <el-option v-for="item in dataTableList" :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                    </el-select>
                </el-col>
            </el-row>
            <el-row type="flex" class="editformitem" align="middle">
                <el-col :span="8" class="editlabel">
                    <span>X轴</span>
                </el-col>
                <el-col :span="16" class="editcontent">
                    <el-select v-model="obj.tableData.xId" filterable clearable placeholder="请选择数据" size="mini">
                        <el-option v-for="item in columnData" :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                    </el-select>
                </el-col>
            </el-row>
            <el-row type="flex" class="editformitem" align="middle" v-for="(item, index) in obj.tableData.yList"
                :key="'selecty' + index">
                <el-col :span="8" class="editlabel">
                    <span>Y轴</span>
                </el-col>
                <el-col :span="16" class="editcontent">
                    <el-select v-model="item.id" placeholder="请选择数据" size="mini" class="tableitemclass">
                        <el-option v-for=" item in columnData" :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                    </el-select>
                    <el-color-picker popper-class="mycolorview" v-model="item.color" size="small" show-alpha
                        :predefine="predefineColors" @active-change="setColorChange(item, 'color', $event)" />
                    <i class="el-icon-error" @click="deleteDataYinfo(obj.tableData.yList, index)"></i>
                </el-col>
            </el-row>
            <div class="addybtn" @click="addDataYinfo(obj.tableData.yList)">
                + 新增Y轴
            </div>
            <!-- <el-row type="flex" class="editformitem">
            <el-col :span="8" class="editlabel">
                <span>数据查询范围</span>
            </el-col>
            <el-col :span="16" class="editcontent">
                <el-select v-model="obj.tableData.filterTimeType" :disabled="obj.tableData.isOnlie" placeholder="选择列时间范围" size="mini"
                    style="width:190px;">
                    <el-option label="15天" :value="15" />
                    <el-option label="1天" :value="1" />
                    <el-option label="7天" :value="7" />
                    <el-option label="30天" :value="30" />
                    <el-option label="90天" :value="90" />
                    <el-option label="1年" :value="365" />
                    <el-option label="全部" :value="99" />
                </el-select>
                <el-tooltip class="item" effect="dark" content="设置数据查询的时间范围，默认查询最近1天" placement="top-start">
                    <i class="el-icon-warning formlabletips"></i>
                </el-tooltip>
            </el-col>
        </el-row> -->
            <el-row type="flex" class="editformitem">
                <el-col :span="8" class="editlabel">
                    <span>自定义Y轴</span>
                </el-col>
                <el-col :span="16" class="editcontent">
                    <el-checkbox v-model="obj.tableData.isSetTranslate"></el-checkbox>
                </el-col>
            </el-row>
            <el-row type="flex" class="editformitem" v-if="obj.tableData.isSetTranslate">
                <el-col :span="8" class="editlabel">
                    <span>Y轴范围</span>
                </el-col>
                <el-col :span="16" class="editcontent dobuleinput">
                    <input placeholder="请输入" type="number" style="width: 80px" v-model.number="obj.tableData.minSize" />
                    <span>-</span>
                    <input placeholder="请输入" type="number" style="width: 80px" v-model.number="obj.tableData.maxSize" />
                </el-col>
            </el-row>
            <el-row type="flex" class="editformitem" align="middle">
                <el-col :span="8" class="editlabel">
                    <span>数据量</span>
                </el-col>
                <el-col :span="16" class="editcontent">
                    <input v-model.number="obj.tableData.count" type="number" />
                </el-col>
            </el-row>
            <el-row type="flex" class="editformitem" align="middle">
                <el-col :span="8" class="editlabel">
                    <span>刷新间隔</span>
                </el-col>
                <el-col :span="16" class="editcontent">
                    <input type="number" v-model.number="obj.tableData.reloadTime" class="miniinput"
                        @change="reloadTimeChangeHandle" />
                    <span>秒</span>
                </el-col>
            </el-row>
        </el-tab-pane>
        <el-tab-pane label="样式">
            <el-collapse v-model="collapseActives" class="edittypeform">
                <el-collapse-item title="图形" name="1">
                    <el-row type="flex" class="editformitem" align="middle">
                        <el-col :span="8" class="editlabel">
                            <span>显示值</span>
                        </el-col>
                        <el-col :span="16" class="editcontent">
                            <el-checkbox v-model="obj.tableData.isShowValue"></el-checkbox>
                            <span style="font-size:14px;margin-right:20px;">网格线</span>
                            <el-checkbox v-model="obj.tableData.isShowGrid"></el-checkbox>
                        </el-col>
                    </el-row>
                    <el-row type="flex" class="editformitem" align="middle">
                        <el-col :span="8" class="editlabel">
                            <span>小数点位</span>
                        </el-col>
                        <el-col :span="16" class="editcontent">
                            <input v-model.number="obj.tableData.decimal" class="miniinput" type="number" />
                        </el-col>
                    </el-row>
                    <el-row type="flex" class="editformitem" align="middle">
                        <el-col :span="8" class="editlabel">
                            <span>散点比例</span>
                        </el-col>
                        <el-col :span="16" class="editcontent">
                            <input v-model.number="obj.tableData.sizeBl" max="20" class="miniinput" type="number" />
                        </el-col>
                    </el-row>
                </el-collapse-item>
                <el-collapse-item title="图例" name="2">
                    <el-row type="flex" class="editformitem">
                        <el-col :span="8" class="editlabel">
                            <span>显示图例</span>
                        </el-col>
                        <el-col :span="16" class="editcontent">
                            <el-checkbox v-model="obj.tableData.isShowLegend"></el-checkbox>
                        </el-col>
                    </el-row>
                    <template v-if="obj.tableData.isShowLegend">
                        <!-- <el-row type="flex" class="editformitem" align="middle">
                        <el-col :span="8" class="editlabel">
                            <span>位置</span>
                        </el-col>
                        <el-col :span="16" class="editcontent">
                            <div class="flex">
                                <div :class="leftPosition(0)" @click="setleftPosition(0)">
                                    <i class="iconfont icon-zuoduiqi"></i>
                                </div>
                                <div :class="leftPosition(1)" @click="setleftPosition(1)">
                                    <i class="iconfont icon-shuipingjuzhongduiqi"></i>
                                </div>
                                <div :class="leftPosition(2)" @click="setleftPosition(2)">
                                    <i class="iconfont icon-youduiqi"></i>
                                </div>
                                <div :class="topPosition(0)" @click="settopPosition(0)">
                                    <i class="iconfont icon-jushangduiqi"></i>
                                </div>
                                <div :class="topPosition(1)" @click="settopPosition(1)">
                                    <i class="iconfont icon-chuizhijuzhongduiqi"></i>
                                </div>
                                <div :class="topPosition(2)" @click="settopPosition(2)">
                                    <i class="iconfont icon-juxiaduiqi"></i>
                                </div>
                            </div>
                        </el-col>
                    </el-row> -->
                        <el-row type="flex" class="editformitem" align="middle">
                            <el-col :span="8" class="editlabel">
                                <span>字体</span>
                            </el-col>
                            <el-col :span="16" class="editcontent sldyinput">
                                <input v-model.number="obj.tableData.textfontSize" class="miniinput" type="number" />
                                <el-color-picker v-model="obj.tableData.textColor" size="small" show-alpha
                                    :predefine="predefineColors" popper-class="mycolorview"
                                    @active-change="setColorChange(obj.tableData, 'textColor', $event)" />
                                <div class="fontstylev">
                                    <div :class="['fontitem', { 'active': obj.tableData.textFontWeight == 'bold' }]"
                                        @click="setFontStyle('fontWeight', obj.tableData, 'textFontWeight')"><i
                                            class="iconfont icon-zitijiacu"></i>
                                    </div>
                                    <div :class="['fontitem', { 'active': obj.tableData.textFontStyle == 'italic' }]"
                                        @click="setFontStyle('fontStyle', obj.tableData, 'textFontStyle')"><i
                                            class="iconfont icon-zitixieti"></i>
                                    </div>
                                </div>
                            </el-col>
                        </el-row>
                        <!-- <el-row type="flex" class="editformitem" align="middle">
                        <el-col :span="8" class="editlabel">
                            <span>排列</span>
                        </el-col>
                        <el-col :span="16" class="editcontent">
                            <el-radio-group v-model="obj.tableData.orient" size="mini">
                                <el-radio-button label="vertical">垂直</el-radio-button>
                                <el-radio-button label="horizontal">水平</el-radio-button>
                            </el-radio-group>
                        </el-col>
                    </el-row> -->
                        <el-row type="flex" class="editformitem" align="middle">
                            <el-col :span="8" class="editlabel">
                                <span>图标</span>
                            </el-col>
                            <el-col :span="16" class="editcontent">
                                <el-radio-group v-model="obj.tableData.icon" size="mini">
                                    <el-radio-button label="circle">圆形</el-radio-button>
                                    <el-radio-button label="rect">矩形</el-radio-button>
                                    <el-radio-button label="triangle">三角形</el-radio-button>
                                </el-radio-group>
                            </el-col>
                        </el-row>
                    </template>
                </el-collapse-item>
                <el-collapse-item title="标题" name="4">
                    <title-form :predefineColors="predefineColors" :obj="obj" :setColorChange="setColorChange"
                        :setFontStyle="setFontStyle"></title-form>
                </el-collapse-item>
            </el-collapse>
        </el-tab-pane>
        <el-tab-pane label="布局">
            <box-form :predefineColors="predefineColors" :obj="obj" :setColorChange="setColorChange"></box-form>
        </el-tab-pane>
    </el-tabs>
</template>

<script>

export default {
    name: "ScatterForm",
    props: {
        predefineColors: Array,
        obj: Object,
        dataTableList: Array,
        columnData: Array,
        tableSelectChange: Function,
        deleteDataYinfo: Function,
        setColorChange: Function,
        addDataYinfo: Function,
        setFontStyle: Function,
        reloadTimeChangeHandle: Function,
    },
    model: {
        prop: "obj",
        event: "change",
    },
    data() {
        return {
            collapseActives: ['1', '2', '3', '4'],
        }
    },
    components: {
        TitleForm: () => import('../mixin/TitleForm.vue'),
        BoxForm: () => import('../mixin/BoxForm.vue'),
    },
}
</script>
